package com.ecoolex.hotel.saas.ws;

import java.math.BigDecimal;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.common.exception.BizException;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.hotel.saas.core.manager.SalesUserManager;
import com.ecoolex.hotel.saas.core.manager.SalesUserWalletDetailManager;
import com.ecoolex.hotel.saas.core.manager.SalesUserWalletManager;
import com.ecoolex.hotel.saas.core.manager.SalesUserWalletWithdrawalApplyManager;
import com.ecoolex.hotel.saas.entity.SalesUser;
import com.ecoolex.hotel.saas.entity.SalesUserWallet;
import com.ecoolex.hotel.saas.entity.SalesUserWalletDetail;
import com.ecoolex.hotel.saas.entity.SalesUserWalletWithdrawalApply;
import com.ecoolex.hotel.saas.pojo.QuerySalesUserDTO;
import com.ecoolex.hotel.saas.pojo.QuerySalesUserWalletWithdrawalApplyDTO;

@Service
public class SalesUserServiceImpl implements SalesUserService{

	@Autowired
	private SalesUserManager salesUserManager;

	@Override
	public SalesUser getSalesUser(Integer id) {
		return salesUserManager.get(id);
	}

	@Override
	public Pagination<SalesUser> querySalesUser(QuerySalesUserDTO query, Page page) {
		return salesUserManager.query(query, page);
	}
	
	@Override
	public SalesUser getByUserIdAndStoreId(Integer userId, Integer storeId) {
		return salesUserManager.getByUserIdAndStoreId(userId, storeId);
	}
	
	@Override
	public Long countByDepartmentId(Integer departmentId) {
		return salesUserManager.countByDepartmentId(departmentId);
	}

	@Override
	public SalesUser addSalesUser(SalesUser add, String createUser) throws BizException {
		return salesUserManager.add(add, createUser);
	}

	@Override
	public SalesUser editSalesUser(SalesUser edit, String updateUser) throws BizException {
		return salesUserManager.edit(edit, updateUser);
	}

	@Autowired
	private SalesUserWalletManager salesUserWalletManager;
	
	@Override
	public SalesUserWallet getSalesUserWalletByUserIdAndStoreId(Integer storeId, Integer userId) {
		return salesUserWalletManager.getByUserIdAndStoreId(userId, storeId);
	}
	
	@Override
	public SalesUserWallet getSalesUserWallet(Integer walletId) {
		return salesUserWalletManager.get(walletId);
	}
	
	@Autowired
	private SalesUserWalletDetailManager salesUserWalletDetailManager;

	@Override
	public Pagination<SalesUserWalletDetail> queryByWalletId(Integer walletId, Page page) {
		return salesUserWalletDetailManager.queryByWalletId(walletId, page);
	}

	@Autowired
	private SalesUserWalletWithdrawalApplyManager withdrawalApplyManager;
	
	@Override
	public SalesUserWalletWithdrawalApply submitApply(Integer walletId, BigDecimal applyAmt, String createUser) throws BizException {
		return withdrawalApplyManager.submitApply(walletId, applyAmt, createUser);
	}

	@Override
	public SalesUserWalletWithdrawalApply getSalesUserWalletWithdrawalApply(Integer applyId) {
		return withdrawalApplyManager.getSalesUserWalletWithdrawalApply(applyId);
	}

	@Override
	public Pagination<SalesUserWalletWithdrawalApply> querySalesUserWalletWithdrawalApply(Integer storeId, Integer userId, Page page) {
		return withdrawalApplyManager.queryForUser(storeId, userId, page);
	}

	@Override
	public Pagination<SalesUserWalletWithdrawalApply> query(QuerySalesUserWalletWithdrawalApplyDTO query, Page page) {
		return withdrawalApplyManager.query(query, page);
	}

	@Override
	public SalesUserWalletWithdrawalApply agree(SalesUserWalletWithdrawalApply apply, String updateUser) throws BizException {
		return withdrawalApplyManager.agree(apply, updateUser);
	}

	@Override
	public SalesUserWalletWithdrawalApply refuse(SalesUserWalletWithdrawalApply apply, String updateUser) throws BizException {
		return withdrawalApplyManager.refuse(apply, updateUser);
	}

}
